﻿using System;
using System.Collections.Generic;
using System.Linq;
using Common.Logging;
using OutDbContext;

namespace Out.Service.Services
{
    public class BizEducation : IDisposable
    {
        private static readonly ILog Logger = LogManager.GetLogger(typeof(BizEducation));

        private readonly GdsfybjyWeiXinEntities _ctx;

        public BizEducation()
        {
            _ctx = new GdsfybjyWeiXinEntities();
        }

        /// <summary>
        /// 获取健康大讲堂列表
        /// </summary>
        /// <param name="educationType"></param>
        /// <returns></returns>
        public List<EducationKnowlg> EducationLists(int educationType)
        {
            return _ctx.EducationKnowlgs.Where(x => x.TypeId == educationType && x.RecStatus == 1).ToList();
        }

        /// <summary>
        /// 获取健康大讲堂详细信息
        /// </summary>
        /// <param name="educationId"></param>
        /// <returns></returns>
        public EducationKnowlg EducationKnowlgDetail(int educationId)
        {
            return _ctx.EducationKnowlgs.FirstOrDefault(x => x.Id == educationId && x.RecStatus == 1);
        }

        /// <summary>
        /// 资源释放
        /// </summary>
        public void Dispose()
        {
            _ctx.Dispose();
        }
    }
}
